﻿using System;
using Newtonsoft.Json;

namespace CkSoftware.GroupMe.Sdk.Groups.Dao
{
	/// <summary>
	/// The DAO for the message overview of a group.
	/// </summary>
	public class GroupMessagesOverviewData
	{
		/// <summary>
		/// The number of messages present in this group.
		/// </summary>
		[JsonProperty(PropertyName = "count")]
		public int Count { get; set; }

		/// <summary>
		/// The DateTime the last message was written in this group.
		/// </summary>
		[JsonIgnore]
		public DateTime LastMessageCreatedAt
		{
			get { return new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(LastMessageCreatedAtSecondsSinceEpoch); }
		}

		/// <summary>
		/// The DateTime the last message was written in this group in unix format (seconds since epoch).
		/// </summary>
		[JsonProperty(PropertyName = "last_message_created_at")]
		public long LastMessageCreatedAtSecondsSinceEpoch { get; set; }

		/// <summary>
		/// The MessageId of the last written message in this group.
		/// </summary>
		[JsonProperty(PropertyName = "last_message_id")]
		public string LastMessageId { get; set; }

		/// <summary>
		/// The preview data for the last group-message.
		/// </summary>
		[JsonProperty(PropertyName = "preview")]
		public GroupMessagesPreviewData Preview { get; set; }
	}
}